package com.customization.unionpay.contract.serivce.impl;

import com.customization.unionpay.contract.dao.BaseContractSynDataDao;
import com.customization.unionpay.contract.serivce.IVirtualContractService;
import com.engine.core.impl.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class VirtualContractServiceImpl  extends Service implements IVirtualContractService {


    @Override
    public boolean contractLedger(int formId, int requestId) {
        //流程主表
        String mainTableName = "";
        String detailTableName = mainTableName + "_dt2";
        addZCContractLedgerByRequestId(requestId,mainTableName,detailTableName);
        return true;
    }

    private boolean addZCContractLedgerByRequestId(int requestId, String mainTableName, String detailTableName) {
        BaseContractSynDataDao baseContractSynDataDao = new BaseContractSynDataDao();
        // 查询合同主表信息
        Map xnContractMain = baseContractSynDataDao.selectXNContractMainByRequestId(mainTableName,requestId);
        // 查询合同明细表信息
        List<Map> skjhContractMX = baseContractSynDataDao.selectZCJHVirtualContractMXByRequestId(requestId,mainTableName,detailTableName);
        // 插入合同台账信息
        baseContractSynDataDao.addZCContractDataLog(xnContractMain);
        // 添加主表信息
        Map main = new HashMap();
        main.put("htmc",xnContractMain.get("htmc"));
        main.put("htbh",xnContractMain.get("htbh"));
        main.put("htskysbde",xnContractMain.get("htskysbde"));
        main.put("htzt",xnContractMain.get("htzt"));
        main.put("htbh",xnContractMain.get("htwb"));

        baseContractSynDataDao.addSKJHContractDataLog(main,skjhContractMX);
        return true;
    }
}
